#include "encodedialog.h"
#include "ui_encodedialog.h"
#include <QDebug>

EncodeDialog::EncodeDialog(QString* outText, NC_Mode* outMode,
    QWidget *parent):
    QDialog(parent),  ui(new Ui::EncodeDialog), text(outText), mode(outMode)
{
    ui->setupUi(this);
    QStringList modes;
    modes << "2 levels" << "3 levels" << "4 levels" << "8 levels";
    ui->comboBox->insertItems(0, modes);
}

EncodeDialog::~EncodeDialog()
{
    delete ui;
}

void EncodeDialog::accept ()
{
    if (text != NULL)
    {
        *text = ui->plainTextEdit->toPlainText();
    }
    if (mode != NULL)
    {
        switch (ui->comboBox->currentIndex())
        {
        case 0:
            *mode = MODE_2_LEVELS;
            break;
        case 1:
            *mode = MODE_3_LEVELS;
            break;
        case 2:
            *mode = MODE_4_LEVELS;
            break;
        case 3:
            *mode = MODE_8_LEVELS;
            break;
        }
    }
    QDialog::accept();
}
